/**
 *   @file MultiChildTree.h
 */
#ifndef _MULTICHILDTREE_H_
#define _MULTICHILDTREE_H_

#include "../../common/BaseObject.h"
#include "../../util/FuncPtrT.h"

namespace cppflib
{

namespace collections
{

namespace tree
{

class MCTreeNode;

// callback function to be called when performing a tree walk
typedef util::FuncPtr1T<void, MCTreeNode&> MCTreeWalkCallback;

/**
 *  A simple tree with multi child.
 *  Root node should have no siblings.
 */
class _DLLAPI MultiChildTree : public BaseObject
{
private:
    MCTreeNode * pRootNode;
    bool uniqueChildKeyOnly;

protected:
    MultiChildTree();

public:
    explicit MultiChildTree(bool uniqueChildKeyOnly);
    virtual ~MultiChildTree(void);

    bool AllowUniqueChildKeyOnly(void);
    bool IsTreeEmpty(void);
    u32_t GetTotalNodeCount(void);
    MCTreeNode * GetRootNode(void);
    virtual void SetRootNode(MCTreeNode * pRootNode);
    void TraverseTree(const MCTreeWalkCallback &treeWalkCB);
    void FreeTree(void);
};

}  // end of namespace tree

}  // end of namespace collections

}  // end of namespace cppflib


#endif
